package cn.imu.appdevexperiment2020.work02;

import android.os.Bundle;
import android.widget.ListView;

import androidx.appcompat.app.AppCompatActivity;

import java.util.ArrayList;
import java.util.List;

import cn.imu.appdevexperiment2020.R;
import cn.imu.appdevexperiment2020.work02.adapter.ItemAdapter;
import cn.imu.appdevexperiment2020.work02.bean.ItemEntity;

public class SecondViewActivity extends AppCompatActivity {
    private List<ItemEntity> data = new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        for (int i = 0; i < 100; i++) {
            data.add(new ItemEntity("item" + i));
        }

        //此项为listview自己需要手动打开
        setContentView(R.layout.activity_second_view);
        ListView list = findViewById(R.id.list_view);
        list.setAdapter(new ItemAdapter(data, this));


        //此项为recycleview 自己需要去掉注释
//        setContentView(R.layout.activity_second_recycle_view);
//        LinearLayoutManager manager = new LinearLayoutManager(this);
//        manager.setOrientation(LinearLayoutManager.VERTICAL);
//        RecyclerView recyclerView= findViewById(R.id.recycle_view);
//        recyclerView.addItemDecoration(new DividerItemDecoration(recyclerView.getContext(), manager.getOrientation()));
//        recyclerView.setLayoutManager(manager);
//        recyclerView.setAdapter(new ItemRecycleViewAdapter(this,data));


    }
}